package com.example.warehousems.event.listener;

import com.example.warehousems.event.event.InOutEvent;
import com.example.warehousems.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class InOutEventListener implements ApplicationListener<InOutEvent> {
    @Autowired
    private WarehouseService warehouseService;
    @Override
    public void onApplicationEvent(InOutEvent event) {
        if (event.getId() == 1) {
            warehouseService.inDone(event.getStorage());
        } else {
            warehouseService.outDone(event.getStorage());
        }
        System.out.println(event);
    }
}
